<?php

namespace app\common\model\xiluedu;

use app\common\model\User;
use think\Model;
use function fast\array_get;


class LotteryLog extends Model
{


    // 表名
    protected $name = 'xiluedu_lottery_log';

    protected $autoWriteTimestamp = 'int';

    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    // 追加属性
    protected $append = [

    ];

    public function user(){
        return $this->belongsTo(User::class,'user_id','id');
    }

    /**
     * 抽奖日志列表
     * @param $params
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public static function lists($params){
        $pagesize = array_get($params,'pagesize',10);
        return static::with(['user'=>function($query){
            $query->withField(['id','nickname','avatar']);
        }])
            ->order('id','desc')
            ->paginate($pagesize);
    }

}
